home *** CD-ROM | disk | FTP | other *** search
- Path: library.erc.clarkson.edu!rpi!not-for-mail
- From: kanze@gabi-soft.fr (J. Kanze)
- Newsgroups: comp.lang.c++,comp.lang.c++.moderated
- Subject: Re: Dynamic class definitions in C++: possible?
- Date: 17 Apr 1996 15:13:49 -0000
- Organization: GABI Software, Sarl.
- Sender: cppmods@netlab.cs.rpi.edu
- Approved: Dietmar.Kuehl@uni-konstanz.de
- Message-ID: <4l31rd$7bj@netlab.cs.rpi.edu>
- References: <4ko91f$1cb@netlab.cs.rpi.edu> <4koodt$2hh@netlab.cs.rpi.edu>
- NNTP-Posting-Host: netlab.cs.rpi.edu
- X-Original-Date: 17 Apr 1996 14:42:11 GMT
-
- In article <4koodt$2hh@netlab.cs.rpi.edu> javaprog@best.com (John
- Lockwood) writes:
-
- |> Kyle.F.Downey@williams.edu (Kyle F. Downey) wrote:
-
- |> >1) load a C++ class definition from a file
- |> >2) convert it to an internal format
- |> >3) use the class just as you would a compiled class
-
- |> >This would allow you to add a class at run-time based on a
- |> >text/user-supplied definition.
-
- |> Why not rethink the problem?
-
- |> 1) Read some data from a file.
- |> 2) Do something with this data using the rich language features that
- |> C++ offers (polymorphism, templates, etc).
- |> 3) Make your program work just as if you'd implemented it using
- |> some wierd JAVA-inspired idea.
-
- |> I'm not trying to be intentionally dense here. If there are problems
- |> that can only be solved in the way you've outlined and not in the way
- |> I have, I'd be interested if you or others would chime in.
-
- There is one frequent use for this sort of thing: upgrading the software
- of an installation without stopping it. For example, if you want a
- telephone switch to handle a new type of terminal, you write the code
- for the new class (which derives from the class `Terminal' already known
- to the system), then add it to a running system.
-
- Coplien discusses several (very) non-portable solutions to do this.
- Under most systems, however, I would see if something along the lines of
- implemening a command to load a DLL in the original software wouldn't
- work. If this is possible, then all you should have to do to add a new
- type is to link the code as a DLL, then load it. (I am also supposing
- here that any static variables in the DLL will be constructed when the
- DLL is loaded. One static variable would contain all of the pertinate
- information concerning the new terminal type, and would register itself
- with the existing software in its constructor.)
- --
- James Kanze (+33) 88 14 49 00 email: kanze@gabi-soft.fr
- GABI Software, Sarl., 8 rue des Francs Bourgeois, 67000 Strasbourg, France
- Conseils en informatique industrielle --
- -- Beratung in industrieller Datenverarbeitung
-
- [ Articles to moderate: mailto:c++-submit@netlab.cs.rpi.edu ]
- [ Read the C++ FAQ: http://www.connobj.com/cpp/cppfaq.htm ]
- [ Moderation policy: http://www.connobj.com/cpp/guide.htm ]
- [ Comments? mailto:c++-request@netlab.cs.rpi.edu ]
-